n, m = input().split()
stu_id = " " + input()
inquire = list(map(int, input().split()))
lst = sorted(inquire)
diet = {}
z = 0
x = 0
for i in lst:
    while z < i:
        x = stu_id.find(" ", x) + 1 # stu_id.find(" ", x)从x开始找到空格并返回空格的索引，没找到则返回-1
        z += 1
    y = stu_id.find(" ", x) # 找到该数后的下一个空格的索引
    diet[i] = stu_id[x:y] # 切片
for i in inquire:
    print(diet[i])
